package com.ndbg.demo.service.threadpool.impl;

import com.ndbg.demo.service.threadpool.AsyncService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class AsyncServiceImpl implements AsyncService {

    // 指定使用beanname为doSomethingExecutor的线程池
    @Async("doSomethingExecutor")
    public String doSomething(String message) {
        for (int i = 0; i < 5; i++) {
            log.info(message + i);
        }
        //try {
        //    Thread.sleep(10);
        //} catch (InterruptedException e) {
        //    log.error("do something error: ", e);
        //}
        return message;
    }
}
